var prefix = ctx + "systool/formbuilder"


$(document).ready(function(){
	queryList();
});

function queryList() {
	var columns = [{
            checkbox: true
        },
        {
            field: 'id',
            title: '模板id'
        },
        {
            field: 'demoName',
            title: '模板名称'
        } ,
        {
            title: '操作',
            align: 'center',
            formatter: function(value, row, index) {
                var actions = [];
                actions.push('<a class="btn btn-success btn-xs" href="#" onclick="model(\'' + row.id + '\')"><i class="fa fa-edit"></i>预览</a> ');
                actions.push('<a class="btn btn-danger btn-xs" href="#" onclick="remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
                return actions.join('');
            }
        }];
	var url = prefix + "/list";
	$.initTable(columns, url);
}

/*模板-新增*/
function add() {
	var url = prefix + '/add'
    layer_show("新增模板", url,'100%','100%');
}

/*预览模板*/
function model(id) {
    var url = prefix + '/model/'+id
    layer_show("预览", url,'100%','100%');
}
// 单条删除
function remove(id) {
    $.modalConfirm("确定要删除选中模板吗？", function() {
        _ajax(prefix + "/remove/" + id, "", "post");
    })
}